/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


$(document).ready(function() {
    $input = $('.field_status').parents().children('input');
    console.log($input.attr('class'));

    $(".sign_up_value, .field_value").focusin(function() {
        $(this).parents().children('.field_status').removeClass('status_invalid status_valid')
    })
    $(".sign_up_value, .field_value").focusout(function() {
        $object_tmp = $(this);
//        alert($(this).attr('class'));
        $object_tmp.parents().children('.field_status').removeClass('status_invalid status_valid');

        $autocheck = setInterval(function() {
//            alert($object_tmp.attr('class'));
            if ($object_tmp.hasClass('success')) {
                $object_tmp.parents().children('.field_status').addClass(function() {
                console.log($(this).attr('class'));
//                if ($(this).hasClass('status_invalid'))
                    $(this).removeClass('status_invalid')
                    clearInterval($autocheck);
                    return 'status_valid';
                })
            }
            else if ($object_tmp.hasClass('error')) {
                $object_tmp.parents().children('.field_status').addClass(function() {
//                console.log($(this).attr('class'));
//                if ($(this).hasClass('status_valid'))
                    $(this).removeClass('status_valid')
//                    clearInterval($autocheck);
                    return 'status_invalid';
                })
            }

        }, 500);

    }
    );


});